﻿
function AddActivity()
{
	var userID=getCookie("userID");
	if(CheckEmpty($('txtTitle'),'warnTitle','活动标题不能为空！')&&
		CheckEmpty($('txtLastDays'),'warnLastDays','活动有效期不能为空！')	&&
		CheckEmpty($('txtMaxNum'),'warnMaxNum','活动最多参加人数不能为空！') && 
		CheckEmpty($('txtDetail'),'warnDetail','活动详细信息不能为空！'))
	{
		var url="activity.php?action=AddActivity";
		
		var para="title="+$('txtTitle').value;
		para+="&lastDays="+$('txtLastDays').value;
		para+="&maxNum="+$('txtMaxNum').value;
		para+="&desc="+$('txtDesc').value;
		para+="&detailInfo="+$('txtDetail').innerHTML;
		para+="&userID="+userID;	
		//para+="&pic="+$('pic').value;	
		alert($('txtDetail').innerHTML);
		
		var response=SendPostRequest(url,para);
		alert(response);
		if(response=="true")
		{
			//var txtAlbumId=document.getElementById('txtAlbumId');//AlbumId
			//var txtAlbumList=document.getElementById('txtAlbumList');
			//alert(txtAlbumList.value);
			//txtAlbumId.value=txtAlbumList.value;//把form表单的txtAlbumId值 用 txtAlbumList 的当前值来赋值
		
			var uploadForm=document.getElementById('uploadForm');//照片txtPhoto连同txtAlbumId 一起上传 由upload_photo.php接
			uploadForm.submit();
		}
	}
}
function CheckEmpty(obj,warnID,warnInfo)
{
	var warnElement=document.getElementById(warnID);
	
	if(obj.value==null || obj.value=="")
	{		
		warnElement.innerText=warnInfo;
		return false;
	}
	else
	{
		warnElement.innerText="OK";
	   return true;
	}
}


function showInsert()
{
	$('insertPic').style.display="block";
}
function hideInsert()
{
	$('insertPic').style.display="none";
}
function InsertPic()
{
	var picUrl=document.getElementById('picURL').value;
	if(picUrl!="")
	{
	   var pic=document.createElement("img");
	   pic.src=picUrl;
	   $('txtDetail').appendChild(pic);
	}
	$('insertPic').style.display="none";
}

function test()
{
	var detail=$('txtDetail').innerHTML;
	alert(detail);
}